unit WinForm;

interface

uses
  System.Drawing, System.Collections, System.ComponentModel,
  System.Windows.Forms, System.Data, System.Globalization, Borland.Data.Provider, 
  System.Data.SqlClient, Borland.Data.Common;

type
  TWinForm = class(System.Windows.Forms.Form)
  {$REGION 'Designer Managed Code'}
  strict private
    /// <summary>
    /// Required designer variable.
    /// </summary>
    Components: System.ComponentModel.Container;

    DataGrid1: System.Windows.Forms.DataGrid;
    Button1: System.Windows.Forms.Button;
    BdpConnection1: Borland.Data.Provider.BdpConnection;
    bdpSelectCommand1: Borland.Data.Provider.BdpCommand;
    bdpInsertCommand1: Borland.Data.Provider.BdpCommand;
    bdpUpdateCommand1: Borland.Data.Provider.BdpCommand;
    bdpDeleteCommand1: Borland.Data.Provider.BdpCommand;
    BdpDataAdapter1: Borland.Data.Provider.BdpDataAdapter;
    DataSet1: System.Data.DataSet;
    GroupBox1: System.Windows.Forms.GroupBox;
    Label2: System.Windows.Forms.Label;
    Label3: System.Windows.Forms.Label;
    TextBox2: System.Windows.Forms.TextBox;
    TextBox3: System.Windows.Forms.TextBox;
    Label1: System.Windows.Forms.Label;
    TextBox1: System.Windows.Forms.TextBox;
    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    procedure InitializeComponent;
   // procedure Button2_Click(sender: System.Object; e: System.EventArgs);
    //procedure Button1_Click(sender: System.Object; e: System.EventArgs);
    procedure TWinForm_Load(sender: System.Object; e: System.EventArgs);
    procedure Button1_Click1(sender: System.Object; e: System.EventArgs);
  {$ENDREGION}
  strict protected
    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    procedure Dispose(Disposing: Boolean); override;
  private
    { Private Declarations }
  public
    constructor Create;
  end;

  [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]

implementation

{$AUTOBOX ON}

{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
begin
  Self.DataGrid1 := System.Windows.Forms.DataGrid.Create;
  Self.Button1 := System.Windows.Forms.Button.Create;
  Self.BdpConnection1 := Borland.Data.Provider.BdpConnection.Create;
  Self.bdpSelectCommand1 := Borland.Data.Provider.BdpCommand.Create;
  Self.bdpInsertCommand1 := Borland.Data.Provider.BdpCommand.Create;
  Self.bdpUpdateCommand1 := Borland.Data.Provider.BdpCommand.Create;
  Self.bdpDeleteCommand1 := Borland.Data.Provider.BdpCommand.Create;
  Self.BdpDataAdapter1 := Borland.Data.Provider.BdpDataAdapter.Create;
  Self.DataSet1 := System.Data.DataSet.Create;
  Self.GroupBox1 := System.Windows.Forms.GroupBox.Create;
  Self.TextBox1 := System.Windows.Forms.TextBox.Create;
  Self.Label1 := System.Windows.Forms.Label.Create;
  Self.TextBox3 := System.Windows.Forms.TextBox.Create;
  Self.TextBox2 := System.Windows.Forms.TextBox.Create;
  Self.Label3 := System.Windows.Forms.Label.Create;
  Self.Label2 := System.Windows.Forms.Label.Create;
  (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).BeginInit;
  (System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).BeginInit;
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).BeginInit;
  Self.GroupBox1.SuspendLayout;
  Self.SuspendLayout;
  // 
  // DataGrid1
  // 
  Self.DataGrid1.DataMember := '';
  Self.DataGrid1.HeaderForeColor := System.Drawing.SystemColors.ControlText;
  Self.DataGrid1.Location := System.Drawing.Point.Create(144, 8);
  Self.DataGrid1.Name := 'DataGrid1';
  Self.DataGrid1.Size := System.Drawing.Size.Create(456, 312);
  Self.DataGrid1.TabIndex := 0;
  // 
  // Button1
  // 
  Self.Button1.Location := System.Drawing.Point.Create(17, 247);
  Self.Button1.Name := 'Button1';
  Self.Button1.Size := System.Drawing.Size.Create(88, 24);
  Self.Button1.TabIndex := 1;
  Self.Button1.Text := 'ʾ';
  Include(Self.Button1.Click, Self.Button1_Click1);
  // 
  // BdpConnection1
  // 
  Self.BdpConnection1.ConnectionOptions := '';
  // 
  // bdpSelectCommand1
  // 
  Self.bdpSelectCommand1.CommandOptions := nil;
  Self.bdpSelectCommand1.CommandText := nil;
  Self.bdpSelectCommand1.CommandType := System.Data.CommandType.Text;
  Self.bdpSelectCommand1.Connection := nil;
  Self.bdpSelectCommand1.ParameterCount := (SmallInt(0));
  Self.bdpSelectCommand1.SchemaName := nil;
  Self.bdpSelectCommand1.Transaction := nil;
  Self.bdpSelectCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
  // 
  // bdpInsertCommand1
  // 
  Self.bdpInsertCommand1.CommandOptions := nil;
  Self.bdpInsertCommand1.CommandText := nil;
  Self.bdpInsertCommand1.CommandType := System.Data.CommandType.Text;
  Self.bdpInsertCommand1.Connection := nil;
  Self.bdpInsertCommand1.ParameterCount := (SmallInt(0));
  Self.bdpInsertCommand1.SchemaName := nil;
  Self.bdpInsertCommand1.Transaction := nil;
  Self.bdpInsertCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
  // 
  // bdpUpdateCommand1
  // 
  Self.bdpUpdateCommand1.CommandOptions := nil;
  Self.bdpUpdateCommand1.CommandText := nil;
  Self.bdpUpdateCommand1.CommandType := System.Data.CommandType.Text;
  Self.bdpUpdateCommand1.Connection := nil;
  Self.bdpUpdateCommand1.ParameterCount := (SmallInt(0));
  Self.bdpUpdateCommand1.SchemaName := nil;
  Self.bdpUpdateCommand1.Transaction := nil;
  Self.bdpUpdateCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
  // 
  // bdpDeleteCommand1
  // 
  Self.bdpDeleteCommand1.CommandOptions := nil;
  Self.bdpDeleteCommand1.CommandText := nil;
  Self.bdpDeleteCommand1.CommandType := System.Data.CommandType.Text;
  Self.bdpDeleteCommand1.Connection := nil;
  Self.bdpDeleteCommand1.ParameterCount := (SmallInt(0));
  Self.bdpDeleteCommand1.SchemaName := nil;
  Self.bdpDeleteCommand1.Transaction := nil;
  Self.bdpDeleteCommand1.UpdatedRowSource := System.Data.UpdateRowSource.None;
  // 
  // BdpDataAdapter1
  // 
  Self.BdpDataAdapter1.Active := False;
  Self.BdpDataAdapter1.DataSet := nil;
  Self.BdpDataAdapter1.DataTable := nil;
  Self.BdpDataAdapter1.DeleteCommand := Self.bdpDeleteCommand1;
  Self.BdpDataAdapter1.InsertCommand := Self.bdpInsertCommand1;
  Self.BdpDataAdapter1.SelectCommand := Self.bdpSelectCommand1;
  Self.BdpDataAdapter1.StartRecord := 0;
  Self.BdpDataAdapter1.UpdateCommand := Self.bdpUpdateCommand1;
  // 
  // DataSet1
  // 
  Self.DataSet1.DataSetName := 'NewDataSet';
  Self.DataSet1.Locale := System.Globalization.CultureInfo.Create('zh-CN');
  // 
  // GroupBox1
  // 
  Self.GroupBox1.Controls.Add(Self.TextBox1);
  Self.GroupBox1.Controls.Add(Self.Label1);
  Self.GroupBox1.Controls.Add(Self.TextBox3);
  Self.GroupBox1.Controls.Add(Self.TextBox2);
  Self.GroupBox1.Controls.Add(Self.Label3);
  Self.GroupBox1.Controls.Add(Self.Label2);
  Self.GroupBox1.Controls.Add(Self.Button1);
  Self.GroupBox1.Location := System.Drawing.Point.Create(8, 2);
  Self.GroupBox1.Name := 'GroupBox1';
  Self.GroupBox1.Size := System.Drawing.Size.Create(128, 318);
  Self.GroupBox1.TabIndex := 2;
  Self.GroupBox1.TabStop := False;
  // 
  // TextBox1
  // 
  Self.TextBox1.Location := System.Drawing.Point.Create(16, 48);
  Self.TextBox1.Name := 'TextBox1';
  Self.TextBox1.TabIndex := 9;
  Self.TextBox1.Text := 'localhost';
  // 
  // Label1
  // 
  Self.Label1.Location := System.Drawing.Point.Create(9, 27);
  Self.Label1.Name := 'Label1';
  Self.Label1.Size := System.Drawing.Size.Create(112, 23);
  Self.Label1.TabIndex := 8;
  Self.Label1.Text := 'ݿ';
  // 
  // TextBox3
  // 
  Self.TextBox3.Location := System.Drawing.Point.Create(16, 192);
  Self.TextBox3.Name := 'TextBox3';
  Self.TextBox3.TabIndex := 7;
  Self.TextBox3.Text := 'stu';
  // 
  // TextBox2
  // 
  Self.TextBox2.Location := System.Drawing.Point.Create(16, 117);
  Self.TextBox2.Name := 'TextBox2';
  Self.TextBox2.TabIndex := 6;
  Self.TextBox2.Text := 'MyDatabase';
  // 
  // Label3
  // 
  Self.Label3.Location := System.Drawing.Point.Create(9, 168);
  Self.Label3.Name := 'Label3';
  Self.Label3.Size := System.Drawing.Size.Create(82, 23);
  Self.Label3.TabIndex := 5;
  Self.Label3.Text := 'ݱ';
  // 
  // Label2
  // 
  Self.Label2.Location := System.Drawing.Point.Create(8, 93);
  Self.Label2.Name := 'Label2';
  Self.Label2.Size := System.Drawing.Size.Create(96, 23);
  Self.Label2.TabIndex := 4;
  Self.Label2.Text := 'ݿ';
  // 
  // TWinForm
  // 
  Self.AutoScaleBaseSize := System.Drawing.Size.Create(6, 14);
  Self.ClientSize := System.Drawing.Size.Create(608, 326);
  Self.Controls.Add(Self.GroupBox1);
  Self.Controls.Add(Self.DataGrid1);
  Self.Name := 'TWinForm';
  Self.Text := 'WinForm';
  Include(Self.Load, Self.TWinForm_Load);
  (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).EndInit;
  (System.ComponentModel.ISupportInitialize(Self.BdpDataAdapter1)).EndInit;
  (System.ComponentModel.ISupportInitialize(Self.DataSet1)).EndInit;
  Self.GroupBox1.ResumeLayout(False);
  Self.ResumeLayout(False);
end;
{$ENDREGION}

procedure TWinForm.Dispose(Disposing: Boolean);
begin
  if Disposing then
  begin
    if Components <> nil then
      Components.Dispose();
  end;
  inherited Dispose(Disposing);
end;

constructor TWinForm.Create;
begin
  inherited Create;
  //
  // Required for Windows Form Designer support
  //
  InitializeComponent;
  //
  // TODO: Add any constructor code after InitializeComponent call
  //
end;

procedure TWinForm.Button1_Click1(sender: System.Object; e: System.EventArgs);
var hostname,database,tablename,SqlStr:string;
begin
    hostname := TextBox1.Text;
    database := TextBox2.Text;
    tablename := TextBox3.Text;
    SqlStr := 'select * from '+tablename;
    //pConnection1.ConnectionOptions := 'transaction isolation=ReadCommitted;blobsize=1024';
    BdpConnection1.ConnectionString := 'assembly=Borland.Data.Mssql, Version=2.0.0.0, Culture=neutral, PublicKeyToken=91d62ebb5b0d1b1b;vendorclient=sqloledb.dll;osauthentication=True;database='+ database +';hostname='+ hostname +';provider=MSSQL';
    BdpDataAdapter1.SelectCommand.CommandText := SqlStr;
    BdpDataAdapter1.SelectCommand.Connection := BdpConnection1;
    DataSet1.Tables.Clear;
    try
        BdpDataAdapter1.Fill(DataSet1);
        DataGrid1.DataSource := DataSet1.Tables[0];
    except on e: Exception do
        MessageBox.Show(e.Message);
    end;
    if BdpConnection1<>nil then
       if BdpConnection1.State = System.Data.ConnectionState.Open then BdpConnection1.Close;
end;

procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs);
begin

end;



end.